import axios from 'axios'
import qs from 'qs'

let baseURL = '/apis'
// 开发环境
if (process.env.NODE_ENV === 'development') {
  baseURL = '/apis'
}
// 正式环境
if (process.env.type === 'production') {
  baseURL = '/apis'
}
// 测试环境
if (process.env.type === 'testing') {
  baseURL = '/apis'
}
axios.defaults.baseURL = baseURL

function dealResponse (response) {
  // 登录超时或没有权限跳转到登陆
  let st = response.data.status
  if (st === 555) {
    window.vm.$router.push({path: '/login'})
    let msg = response.data.msg ? response.data.msg : '请重新登陆！'
    window.vm.$Message.error(msg)
    return true
  } else {
    return false
  }
}

// 给post 添加 中断请求
window.sourceData = []

function myAxios (option) {
  // axios post 提交数据，后台获取不到提交的数据解决方案
  if (option.headers === undefined && option.method === 'POST' && option.data) {
    axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
    // 坑，qs.stringify处理的对象中，key对应的值不能有json字符串（对象or数组）
    option.data = qs.stringify(option.data)
  }
  // 避免数组数据太多
  if (window.sourceData.length > 300) {
    window.sourceData = window.sourceData.slice(200, window.sourceData.length)
  }
  let source = axios.CancelToken.source()
  window.sourceData.push(source)
  option.cancelToken = source.token
  return axios(option).then(function (response) {
    if (dealResponse(response)) {
      return
    }
    return Promise.resolve(response)
  }).catch(function (error) {
    if (error.message === '取消请求') {
      // 中断请求返回一个 promise
      return new Promise((resolve, reject) => {
        resolve({status: 999})
      })
    }
    if (dealResponse(error.response)) {
      return
    }
    return Promise.reject(error)
  })
}

// `responseType` 表示服务器响应的数据类型，可以是 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'
// responseType: 'json', // 默认的
// get传参数用params,
// 'PUT', 'POST', 和 'PATCH'传参数用 data
let api = {
  do_get: function (url) {
    // 通用 get 接口
    let option = {method: 'GET', url: url}
    return myAxios(option)
  },
  do_gett: function (url, data) {
    // 通用 get 接口
    let option = {method: 'GET', url: url, params: data}
    return myAxios(option)
  },
  do_post: function (url, data) {
    // 通用 post 接口
    let option = {method: 'POST', url: url, data: data}
    return myAxios(option)
  },
  do_download: function (url, data) {
    // 通用 下载文件 接口
    let option = {method: 'POST', url: url, data: data, responseType: 'blob'}
    return myAxios(option)
  },
  do_put: function (url, data) {
    // 通用 post 接口
    let option = {method: 'PUT', url: url, data: data}
    return myAxios(option)
  },
  put_post: function (url, data, method) {
    // 通用 post 接口
    let option = {
      method: method,
      url: url,
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  post_json: function (url, data) {
    // 通用 删除 调用
    let option = {
      method: 'POST',
      url: url,
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  do_del: function (url, data) {
    // 通用 删除 调用
    let option = {
      method: 'DELETE',
      url: url,
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  upload: function (url, data) {
    // 通用上传方法
    let option = {method: 'POST', url: url, data: data, headers: {'Content-Type': 'multipart/form-data'}}
    return myAxios(option)
  },
  kaptcha: function () {
    // 接受二进制流数据
    let option = {method: 'GET', url: '/kaptcha.jpg', responseType: 'blob'}
    return myAxios(option)
  },
  show_pic: function (data) {
    // 接受二进制流数据
    let option = {method: 'POST', url: '/$pic/visit', data: data, responseType: 'arraybuffer'}
    return myAxios(option)
  },
  login: function (data) {
    let option = {method: 'POST', url: '/login', data: data}
    return myAxios(option)
  },
  // 后台配置---数据
  quota_save: function (data) {
    let option = {
      method: 'POST',
      url: '/$quota/save',
      data: data,
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  quota_del: function (data) {
    let option = {
      method: 'DELETE',
      url: '/$quota/del',
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  quota_info_id: function (data) {
    let option = {method: 'GET', url: '/$quota/info/' + data.id}
    return myAxios(option)
  },
  quota_list: function (data) {
    let option = {method: 'GET', url: '/$quota/list', params: data}
    return myAxios(option)
  },
  quota_upd: function (data) {
    let option = {method: 'PUT', url: '/$quota/upd', data: data}
    return myAxios(option)
  },
  // 安全监控---视频
  security_dev_sums: function (data) {
    let option = {
      method: 'POST',
      url: '/$security/dev&sums',
      data: data,
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },

  // xxx能耗总揽--汇总
  carbon_allin: function (data) {
    let option = {method: 'POST', url: '/$carbon/allin', data: data}
    return myAxios(option)
  },
  // xxx能耗总揽--单车
  carbon_avgs: function (data) {
    let option = {method: 'POST', url: '/$carbon/avgs', data: data}
    return myAxios(option)
  },
  // xxx能耗总揽--报表
  carbon_form: function (data) {
    let option = {method: 'POST', url: '/$carbon/form', data: data}
    return myAxios(option)
  },
  // xxx能耗总揽--下载报表
  carbon_dform: function (data) {
    let option = {method: 'POST', url: '/$carbon/dform', data: data}
    return myAxios(option)
  },
  // xxx汇总碳排--总碳排,单车碳排,总产量,平均温度
  carbon_allCarBon: function (data) {
    let option = {method: 'POST', url: '/$carbon/allCarBon', data: data}
    return myAxios(option)
  },
  // xxx汇总碳排--总碳排,单车碳排,总产量,平均s温度s
  carbons_allCarBon: function (data) {
    let option = {method: 'POST', url: '/enManager/allCarList', data: data}
    return myAxios(option)
  },
  // xxx汇总碳排-- 碳排走势
  carbon_carbonTrend: function (data) {
    let option = {method: 'POST', url: '/$carbon/carbonTrend', data: data}
    return myAxios(option)
  },
  // xxx汇总碳排-- 子级占比排名
  carbon_carbonTrendSon: function (data) {
    let option = {method: 'POST', url: '/$carbon/carbonTrendSon', data: data}
    return myAxios(option)
  },
  // xxx汇总碳排-- 同类对比
  carbon_sameCompare: function (data) {
    let option = {method: 'POST', url: '/$carbon/sameCompare', data: data}
    return myAxios(option)
  },
  // xxx汇总碳排-- 类型占比/排名
  carbon_typePercent: function (data) {
    let option = {method: 'POST', url: '/$carbon/typePercent', data: data}
    return myAxios(option)
  },
  // xxx汇总碳排-- 过往排名
  carbon_lastRanking: function (data) {
    let option = {method: 'POST', url: '/$carbon/carbRanking', data: data}
    return myAxios(option)
  },
  // xxx汇总碳排-- 过往对比/过往排名
  carbon_lastCompare: function (data) {
    let option = {method: 'POST', url: '/$carbon/lastCompare', data: data}
    return myAxios(option)
  },
  // xxx获取 日期的年月日树形数据
  ttrees: function (data) {
    let option = {method: 'GET', url: '/$carbon/ttrees', params: data}
    return myAxios(option)
  },
  // 车间选择  树形数据
  ensTree: function (data) {
    let option = {method: 'POST', url: '/ens/tree', data: data}
    return myAxios(option)
  },
  // xxx能耗总揽--能耗总揽--报表--能源详情数据
  formDetail: function (data) {
    let option = {method: 'POST', url: '/$carbon/formDetail', data: data}
    return myAxios(option)
  },

  // 能源监控---碳排&对比
  // 汇总碳排,单车碳排,综合产量
  carbon_total: function (data) {
    let option = {method: 'POST', url: '/$carbon/total', data: data}
    return myAxios(option)
  },
  // 单类能源碳排
  carbon_energy: function (data) {
    let option = {method: 'POST', url: '/$carbon/energy', data: data}
    return myAxios(option)
  },
  // 汇总--碳排走势
  carbon_total_chart: function (data) {
    let option = {method: 'POST', url: '/$carbon/total&chart', data: data}
    return myAxios(option)
  },
  // 汇总--子级对比
  carbon_total_sublevel_chart: function (data) {
    let option = {method: 'POST', url: '/$carbon/total&sublevel&chart', data: data}
    return myAxios(option)
  },
  // 单车--碳排走势
  carbon_avg_chart: function (data) {
    let option = {method: 'POST', url: '/$carbon/trendAvg', data: data}
    return myAxios(option)
  },
  // 单车--子级对比
  carbon_avg_sublevel_chart: function (data) {
    let option = {method: 'POST', url: '/$carbon/avg&sublevel&chart', data: data}
    return myAxios(option)
  },
  // --子级对比
  carbonSubset: function (data) {
    let option = {method: 'POST', url: '/$carbon/subset', data: data}
    return myAxios(option)
  },
  // 能源监控--对比
  carbon_comparison: function (data) {
    let option = {method: 'POST', url: '/$carbon/comparison', data: data}
    return myAxios(option)
  },
  // 获取当前登录者的信息
  get_information: function (data) {
    let option = {method: 'GET', url: '/$user/current', data: data}
    return myAxios(option)
  },
  // 当前用户修改密码
  changePw: function (data) {
    let option = {method: 'POST', url: '/$user/changePw', data: data}
    return myAxios(option)
  },
  // 设备类型接口
  devType_save: function (data) {
    let option = {
      method: 'POST',
      url: '/iot/devType/save',
      data: data,
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  devType_del: function (data) {
    let option = {
      method: 'DELETE',
      url: '/iot/devType/del',
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  devType_list: function (data) {
    let option = {method: 'GET', url: '/iot/devType/list', params: data}
    return myAxios(option)
  },
  devType_upd: function (data) {
    let option = {method: 'PUT', url: '/iot/devType/upd', data: data}
    return myAxios(option)
  },
  dev_icons: function (data) {
    let option = {method: 'GET', url: '/iot/devType/icons', data: data}
    return myAxios(option)
  },
  // 设备接口
  dev_save: function (data) {
    let option = {
      method: 'POST',
      url: '/iot/dev/save',
      data: data,
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  dev_del: function (data) {
    let option = {
      method: 'DELETE',
      url: '/iot/dev/del',
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  dev_list: function (data) {
    let option = {method: 'GET', url: '/iot/dev/list', params: data}
    return myAxios(option)
  },
  dev_upd: function (data) {
    let option = {method: 'PUT', url: '/iot/dev/upd', data: data}
    return myAxios(option)
  },
  dev_sid: function (data) {
    let option = {
      method: 'POST',
      url: '/iot/dev/sid',
      data: data,
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  // 空间接口
  space_save: function (data) {
    let option = {
      method: 'POST',
      url: '/iot/space/save',
      data: data,
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  space_del: function (data) {
    let option = {
      method: 'DELETE',
      url: '/iot/space/del',
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  space_del_all: function (data) {
    let option = {
      method: 'POST',
      url: '/iot/space/deleteSpaceDev',
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  space_list: function (data) {
    let option = {method: 'GET', url: '/iot/space/list', params: data}
    return myAxios(option)
  },
  space_upd: function (data) {
    let option = {method: 'PUT', url: '/iot/space/upd', data: data}
    return myAxios(option)
  },
  space_info: function (data) {
    let option = {method: 'GET', url: '/iot/space/info', params: data}
    return myAxios(option)
  },
  space_tree: function (data) {
    //  获取 空间的 级联数选择数据
    let option = {method: 'POST', url: '/iot/space/cas', params: data}
    return myAxios(option)
  },
  // 首页关注设备数据
  follow_devs: function (data) {
    //  获取 当前用户关注的设备信息
    let option = {method: 'POST', url: '/$follow/list', data: data}
    return myAxios(option)
  },
  do_follow: function (data) {
    //  关注设备
    let option = {
      method: 'POST',
      url: '/$follow/follow',
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  cancel_follow: function (data) {
    //  取消关注设备
    let option = {
      method: 'POST',
      url: '/$follow/cancel',
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  cur_data: function (data) {
    //  获取实时数据
    let option = {method: 'POST', url: '/iot/dev/curData', data: data}
    return myAxios(option)
  },
  // 字典数据
  dict_list: function (data) {
    let option = {method: 'GET', url: '/dict/list', params: data}
    return myAxios(option)
  },
  dict_save: function (data) {
    let option = {
      method: 'POST',
      url: '/dict/save',
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  dict_update: function (data) {
    let option = {
      method: 'PUT',
      url: '/dict/upd',
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  dict_delete: function (data) {
    let option = {
      method: 'DELETE',
      url: '/dict/del',
      data: JSON.stringify(data),
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  dict_opts: function (data) {
    let option = {method: 'GET', url: '/dict/opts', data: data}
    return myAxios(option)
  },
  sys_list: function (data) {
    let option = {method: 'POST', url: '/sysimg/list', data: data}
    return myAxios(option)
  },
  space_under_devs: function (data) {
    // 空间下 所有的子级关联的设备数据
    let option = {method: 'POST', url: 'iot/dev/spaceAllDevs', data: data}
    return myAxios(option)
  },
  // 设备数据查询
  iotDevRealData: function (data) {
    let option = {method: 'POST', url: '/iot/dev/realData', data: data}
    return myAxios(option)
  },
  config_dev_list: function (data) {
    let option = {method: 'GET', url: '/condev/list', params: data}
    return myAxios(option)
  },
  config_dev_save: function (url, data, method) {
    let option = {
      method: method,
      url: url,
      data: data,
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  // 能源接线图
  iotDevCurSysLineData: function (data) {
    let option = {method: 'POST', url: 'iot/dev/curSysLineData', data: data}
    return myAxios(option)
  },
  // 能源接线图(new)
  getAdminMeasureTreeData: function (data) {
    let option = {method: 'POST', url: 'iot/dev/getAdminMeasureTreeData', data: data}
    return myAxios(option)
  },
  /*
  *
  * 空压系统 的接口新的 2019年 05月 07 日
  */
  // 获取空压下拉框的 接口方法
  getStation (data) {
    let option = {method: 'POST', url: 'iot/space/stations', data: data}
    return myAxios(option)
  },
  // 空压系统 工艺控制的接口方法
  getSttDevs (data) {
    let option = {method: 'POST', url: 'iot/dev/sttDevs', data: data}
    return myAxios(option)
  },
  // 7月01 日新需求修改
  getSpaceIdDevs (data) {
    let option = {method: 'POST', url: '/iot/dev/getSpaceIdDevs', data: data}
    return myAxios(option)
  },
  // 定时刷新接口
  postTimer (data) {
    let option = {method: 'POST', url: 'iot/dev/cur', data: data}
    return myAxios(option)
  },
  // 现场自动，远程人工，参数设定的 接口
  updParam (data) {
    let option = {
      method: 'POST',
      url: 'iot/dev/updParam',
      data: data,
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  // 点击各个 机器图片 请求 返回的 数据 图表方法
  devItemData (data) {
    let option = {method: 'POST', url: 'iot/dev/devItemData', data: data}
    return myAxios(option)
  },
  // 点击各个 机器图片 里面的 下载表格的方法
  downDevItemData (data) {
    let option = {method: 'POST', url: 'iot/dev/downDevItemData', data: data, responseType: 'blob'}
    return myAxios(option)
  },
  // 一键开机和一键关机 的 控制 gif 图片的 接口
  cmdByIdd (data) {
    let option = {method: 'POST', url: 'iot/dev/cmdById', data: data}
    return myAxios(option)
  },
  // 自定义页面对比接口 module
  getComparisonData (module, data) {
    let option = {
      method: 'POST',
      url: '/$carbon/' + `${module}`,
      headers: {'Content-Type': 'application/json;charset=UTF-8'},
      data: data
    }
    return myAxios(option)
  },
  /*
  *  7月01日 新需求 获取mTabs 分页的 数据 的接口
  * */
  getTabs (data) {
    let option = {method: 'POST', url: 'iot/space/titles', data: data}
    return myAxios(option)
  },
  // 通过分页 id 获取各个设备的id
  getTabsDevids (data) {
    let option = {method: 'POST', url: 'iot/dev/devids', data: data}
    return myAxios(option)
  },
  // 供冷计量 的 请求接口
  getCoolingOrAir (data) {
    let option = {method: 'POST', url: 'iot/dev/loadVisionDevs', data: data}
    return myAxios(option)
  },
  /**
   * 7月27日 新需求工艺能效的接口改变
   */
  getEnergyEffi (data) {
    let option = {
      method: 'POST',
      url: 'iot/dev/sondids',
      data: data
    }
    return myAxios(option)
  },
  /*
  *  8月26日新需求 更改的 接口
  * */
  // 车间选择  树形数据
  postSpace (data) {
    let option = {method: 'POST', url: '/ens/ecss', data: data}
    return myAxios(option)
  },
  // nav 导航 的请求接口/ens/menus?spaces=PV-郑州工厂-冲压车间
  postNav (data) {
    let option = {method: 'POST', url: '/ens/menus', data: data}
    return myAxios(option)
  },
  // ems浅色版车间级左侧数据
  workShopList (data) {
    let option = {method: 'POST', url: 'iot/dev/workshopFirstLevelData', data: data}
    return myAxios(option)
  },
  /**
   *  9月29新增母排接口 [供电系统]
   * */
  // 获取母排下拉列表跟按钮数据
  getEleTab (data) {
    let option = {method: 'POST', url: 'iot/space/busbarSpaces', data: data}
    return myAxios(option)
  },
  // 获取母线下面的设备
  getEleDevice (data) {
    let option = {method: 'POST', url: 'iot/space/pageIotDevBySpaceId', data: data}
    return myAxios(option)
  },
  // 获取单个设备数据
  singleDevice (data) {
    let option = {method: 'POST', url: 'iot/space/loadIotDevCurData', data: data}
    return myAxios(option)
  },
  // 供电系统 单击俩行 的每个设备 的 弹窗
  eleLineEcharts (data) {
    let option = {method: 'POST', url: 'iot/space/temperatureTrend', data: data}
    return myAxios(option)
  },
  // 获取报警信息的 列表接口
  getAlarmList (data) {
    let option = {method: 'GET', url: 'alarmMessage/list', params: data}
    return myAxios(option)
  },
  // 报警信息 列表里每一行处理 的接口方法
  dealAlarm (data) {
    let option = {method: 'POST', url: 'alarmMessage/update', data: data}
    return myAxios(option)
  },
  // 报警预设 温度上下限
  alarmTem (data) {
    let option = {method: 'POST', url: 'iot/space/alarmParams', data: data}
    return myAxios(option)
  },
  // 设备诊断下拉框数据
  SelectData (data) {
    let option = {method: 'POST', url: 'iot/space/busDevItems', data: data}
    return myAxios(option)
  },
  // 设备诊断 -- 查询设备名称或者编号是否存在
  diagnosisDev (url, data) {
    let option = {
      method: 'POST',
      url: `iot/space/${url}`,
      data: data,
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  // 报警预设更新 提交 温度上下限
  alarmTemUpdate (data) {
    let option = {
      method: 'POST',
      url: 'iot/space/alarmSystem',
      data: data,
      headers: {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  },
  // 复位报警源 接口
  resetAlarm () {
    let option = {method: 'POST', url: 'alarmMessage/resetAlarmInfo'}
    return myAxios(option)
  },
  // 报警灯 定时刷新请求
  alarmStatus (data) {
    let option = {method: 'POST', url: 'iot/space/workShopAlarmStatus', data: data}
    return myAxios(option)
  },
  // 母排 图表的 下载表格
  downBusDevData (data) {
    let option = {method: 'POST', url: 'alarmMessage/downloadTable', data: data, responseType: 'blob'}
    return myAxios(option)
  }
}
// 新接口的定义
// let newApi = {
//   postData: (data = {}, type = '', flag = false) => {
//     let option = {
//       method: type,
//       url: '/iot/dev/curData',
//       data: data
//     }
//     if (flag) {
//       option['headers'] = { 'Content-Type': 'application/json;charset=UTF-8' }
//     }
//     return myAxios(option)
//   }
// }
// 新接口 模式 的 类
class Api {
  constructor (data = {}, type = '', flag = false) {
    // 公共请求 需要传 的参数
    this.data = data
    this.type = type
    this.flag = flag
    // 每一个 请求的参数 id(唯一标识)
    this.totalOverview = 10343 // 总览设备id
    this.postForm = 10354 // 总览设备报表id
    // EMS 碳排接口
    this.totalCarbon = 10336 // 总碳排
    this.carbonTrend = 10337 // 碳排走势
    this.carbonTypeRank = 10338 // 碳排类型占比
    this.carbonChildRank = 10339 // 碳排子级占比/排行
    this.carbonPastComparison = 10340 // 碳排过往对比
    this.carbonSimilarContrast = 10341 // 碳排同类对比
    this.carbonPastRanking = 10342 // 碳排过往排行
    // EMS 成本的接口
    this.costCarbon = 10325 // 总成本
    this.costTrend = 10327 // 成本走势
    this.costTypeRank = 10328 // 成本类型占比
    this.costChildRank = 10330 // 成本子级占比/排行
    this.costPastComparison = 10331 // 成本过往对比
    this.costSimilarContrast = 10333 // 成本同类对比
    this.costPastRanking = 10335 // 成本过往排行
    // EMS 用水的接口
    this.waterBicy = 10315 // 总用水
    this.waterTrend = 10316 // 用水走势
    this.waterTypeRank = 10317 // 用水类型占比
    this.waterChildRank = 10318 // 用水子级占比/排行
    this.waterPastComparison = 10319 // 用水过往对比
    this.waterSimilarContrast = 10320 // 用水同类对比
    this.waterPastRanking = 10321 // 用水过往排行

    // EMS 用电的接口
    this.electricBicy = 10301 // 总用电
    this.electricTrend = 10302 // 用电走势
    this.electricTypeRank = 10303 // 类型占比排行
    this.electricChildRank = 10304 // 子级占比排名
    this.electricPastComparison = 10305 // 过往对比
    this.electricSimilarContrast = 10306 // 同类对比 厂区， 总量，年涨幅
    this.electricPastRanking = 10307 // 过往排名 年 总量
    // EMS 燃气的接口
    this.totalGas = 10308 // 总燃气
    this.gasTrend = 10309 // 燃气走势
    this.gasTypeRank = 10310 // 燃气类型占比排行
    this.gasChildRank = 10311 // 燃气子级占比排名
    this.gasPastComparison = 10312 // 燃气过往对比
    this.gasSimilarContrast = 10313 // 燃气同类对比 厂区， 总量，年涨幅
    this.gasPastRanking = 10314 // 燃气过往排名 年 总量
    // EMS 冷量的接口
    this.coldBicy = 10283 // 总冷量
    this.coldTrend = 10285 // 冷量走势
    this.coldTypeRank = 10286 // 冷量类型占比排行
    this.coldchildRank = 10287 // 冷量子级占比排名
    this.coldPastComparison = 10288 // 冷量过往对比
    this.coldSimilarContrast = 10289 // 冷量同类对比 厂区， 总量，年涨幅
    this.coldPastRanking = 10290 // 冷量过往排名 年 总量
    // EMS 蒸汽的接口
    this.totalSteam = 10322 // 总蒸汽
    this.steamTrend = 10323 // 蒸汽走势
    this.steamTypeRank = 10324 // 蒸汽类型占比排行
    this.steamChildRank = 10326 // 蒸汽子级占比排名
    this.steamPastComparison = 10329 // 蒸汽过往对比
    this.steamSimilarContrast = 10332 // 蒸汽同类对比 厂区， 总量，年涨幅
    this.steamPastRanking = 10334 // 蒸汽过往排名 年 总量
    // EMS 空气的接口
    this.airBicy = 10291 // 总空气
    this.airTrend = 10293 // 空气走势
    this.airTypeRank = 10294 // 类型占比排行
    this.airchildRank = 10295 // 子级占比排名
    this.airPastComparison = 10296 // 过往对比
    this.airSimilarContrast = 10297 // 同类对比 厂区， 总量，年涨幅
    this.airPastRanking = 10298 // 过往排名 年 总量
    // 空压系统
    // 工艺能效接口
    this.consumeEnergy = 10362 // 耗能趋势图
  }

  getData () {
    let option = {
      method: this.type,
      url: '/iot/dev/curData/' + this.data.id,
      data: this.data
    }
    if (this.flag) {
      option['headers'] = {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  }

  // 空压系统 工艺监视--空压机房的接口方法
  getComporData () {
    let option = {
      method: this.type,
      url: '/iot/dev/cur/?' + this.data.id,
      data: this.data
    }
    if (this.flag) {
      option['headers'] = {'Content-Type': 'application/json;charset=UTF-8'}
    }
    return myAxios(option)
  }
}

export {
  api,
  Api
}
